package java101;

import junit.framework.TestCase;

public class GeoTestLon extends TestCase {

	public void testLongitude() {
		Longitude equator = new Longitude(0.);
		assertEquals(0., equator.getDeg());
		Longitude northPole = new Longitude(180.);
		assertEquals(180., northPole.getDeg());
	}
	
	public void testNewLonDMS() {
		Longitude lon = new Longitude(60,0,3.6);
		assertEquals(60.001, lon.getDeg(), 1e-12); //third field = margin of error to account for end of decimal 'double' errors
	}
	
	public void testNewLonDMSOUtofRangeMax() {
		try {
			Longitude outofRangeMax = new Longitude(180,0,1);
			fail ("Should have thrown exception");
		} catch (IllegalArgumentException e) {
			// passed (because it failed)
		}
	}
	
	public void testOutOfRangeMax() {
		try {
			Longitude outOfRangeMax = new Longitude(180.1);
			fail("Should have thrown exception");
		} catch (IllegalArgumentException e) {
			// passed (because it failed)
		}
		
	}
	public void testOutOfRangeMin() {
		try {
			Longitude outOfRangeMin = new Longitude(-180.1);
			fail("Should have thrown exception");
		} catch (IllegalArgumentException e) {
			// passed (because it failed)
		}
	}
	}
	

